#include "openrgss.h"

ORGSSModule ORGSSGraphicsModule, ORGSSInputModule, ORGSSAudioModule;

void ORGSS_Init ( ORGSSGraphicsMList *gMList, ORGSSInputMList *iMList, ORGSSAudioMList *aMList ) {
	/* -- Initialize Ruby -- */
	ruby_init();
	
	/* -- Initialize Graphics -- */
	ORGSSGraphicsModule = rb_define_module("Graphics");
	rb_define_module_function(ORGSSGraphicsModule, "update", gMList->update, 0);
	rb_define_module_function(ORGSSGraphicsModule, "fullscreen?", gMList->fullscreen_get, 0);
	rb_define_module_function(ORGSSGraphicsModule, "fullscreen=", gMList->fullscreen_set, 1);
	rb_define_module_function(ORGSSGraphicsModule, "freeze", ORGSSGraphicsFreezeMethod, 0);
	
	/* -- Initialize Input -- */
	ORGSSInputModule = rb_define_module("Input");
	rb_define_module_function(ORGSSInputModule, "update", iMList->update, 0);
	rb_define_module_function(ORGSSInputModule, "trigger?", ORGSSInputTrigger, -1);
	rb_define_module_function(ORGSSInputModule, "release?", ORGSSInputRelease, -1);
	rb_define_module_function(ORGSSInputModule, "press?", ORGSSInputPress, -1);
	
	/* -- Initialize Audio -- */	
	ORGSSAudioModule = rb_define_module("Audio");
	rb_define_module_function(ORGSSAudioModule, "play_bgm", aMList->play_bgm, 3);
	rb_define_module_function(ORGSSAudioModule, "stop_bgm", aMList->stop_bgm, 0);	
	rb_define_module_function(ORGSSAudioModule, "play_bgs", aMList->play_bgs, 3);
	rb_define_module_function(ORGSSAudioModule, "play_me", aMList->play_me, 3);
	rb_define_module_function(ORGSSAudioModule, "play_se", aMList->play_se, 3);
	rb_define_module_function(ORGSSAudioModule, "stop_se", aMList->stop_se, 0);	
}

void ORGSS_Main ( void ) {
	rb_load_file("main.rb");
	
	ruby_run();
}